
/* tiku.scratchor.com/paper/view/qmbrvr3oxupyfljg */
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 10;
int dp[maxn][maxn], a[maxn][maxn];
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= i; j++) cin >> a[i][j];
  }
  memset(dp, 0, sizeof(dp));
  dp[1][1] = a[1][1];
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = max(dp[i - 1][j - 1], dp[i - 1][j]) + a[i][j];
    }
  }
  int m = dp[n][1];
  for (int i = 2; i < n; i++) {
    m = max(m, dp[n][i]);
  }
  cout << m << endl;
}